<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app">
      <div>
        <p v-if="flag">username <input key="a" type="text" /></p>
        <p v-else>email <input key="b" type="text" /></p>
        <button @click="set">set</button>
      </div>
    </div>
    <script src="./vue.js"></script>
    <script>
      usernameInput = "<input key='a'></input>"; //old
      emailInput = "<input key='a'></input>"; //new

      new Vue({
        el: "#app",
        data: {
          flag: true,
        },
        methods: {
          set() {
            this.flag = !this.flag;
          },
        },
      });
    </script>
  </body>
</html>
